from selenium.webdriver.common.by import By
from selenium import webdriver
from confing import URL, Login, PassWord
from time import sleep
# Using Chrome to access web
driver = webdriver.Chrome()
def LogIn():
    # Open the website
    driver.get(URL)

    login_box = driver.find_element(By.ID, "username")
    login_box.send_keys(Login)

    pass_box = driver.find_element(By.ID, "password")
    pass_box.send_keys(PassWord)

    login_button = driver.find_element(By.ID, "loginbtn")
    login_button.click()
    return True



def GoToTest():
    sleep(1)
    xbut = driver.find_element(By.XPATH, "/html/body/div[1]/div[3]/div/div/section/div[1]/div[2]/div/form/button")
    xbut.click()


def sloveTest():

    qu1box = driver.find_element(By.XPATH, "/html/body/div[1]/div[3]/div/div/section[1]/div[1]/form/div/div[1]/div[2]/div/div[2]/label/span/input")
    qu1box.send_keys("77⁰15ʹ")
    nextbtn = driver.find_element(By.NAME, "next")
    nextbtn.click()

    qu2box = driver.find_element(By.XPATH, "/html/body/div[1]/div[3]/div/div/section[1]/div[1]/form/div/div[1]/div[2]/div/div[2]/label/span/input")
    qu2box.send_keys("4ч6м")
    nextbtn = driver.find_element(By.NAME, "next")
    nextbtn.click()

    qu3dut = driver.find_element(By.XPATH,"/html/body/div[1]/div[3]/div/div/section[1]/div[1]/form/div/div[1]/div[2]/div/div[2]/div[2]/div[1]/label")
    qu3dut.click()
    nextbtn = driver.find_element(By.NAME, "next")
    nextbtn.click()

    qu4dut = driver.find_element(By.XPATH, "/html/body/div[1]/div[3]/div/div/section[1]/div[1]/form/div/div[1]/div[2]/div/div[2]/div[2]/div[2]/label")
    qu4dut.click()
    nextbtn = driver.find_element(By.NAME, "next")
    nextbtn.click()

    qu5dut = driver.find_element(By.XPATH, "/html/body/div[1]/div[3]/div/div/section[1]/div[1]/form/div/div[1]/div[2]/div/div[2]/div[2]/div[1]/label")
    qu5dut.click()
    nextbtn = driver.find_element(By.NAME, "next")
    nextbtn.click()


    qu6box = driver.find_element(By.XPATH, "/html/body/div[1]/div[3]/div/div/section[1]/div[1]/form/div/div[1]/div[2]/div/div[2]/label/span/input")
    qu6box.send_keys("Вега")
    nextbtn = driver.find_element(By.NAME, "next")
    nextbtn.click()
    sleep(1)
    variants = driver.find_elements(By.TAG_NAME, "p")#7
    for i in variants:
        match i.text:
            case "Вешалка":
                i.click()
            case "Каскад Кэмбла":
                i.click()
            case "Рождественский гусь":
                i.click()
            case "Летний треугольник":
                i.click()
            case "Гроб Иакова":
                i.click()
            case "Воздушный змей Кэмбла":
                i.click()
    nextbtn = driver.find_element(By.NAME, "next")
    nextbtn.click()

    qu8dut = driver.find_element(By.XPATH, "/html/body/div[1]/div[3]/div/div/section[1]/div[1]/form/div/div[1]/div[2]/div/div[2]/div[2]/div[2]/label")
    qu8dut.click()
    nextbtn = driver.find_element(By.NAME, "next")
    nextbtn.click()

    qu9dut = driver.find_element(By.XPATH, "/html/body/div[1]/div[3]/div/div/section[1]/div[1]/form/div/div[1]/div[2]/div/div[2]/div[2]/div[1]/label")
    qu9dut.click()
    nextbtn = driver.find_element(By.NAME, "next")
    nextbtn.click()
    sleep(1)
    variants = driver.find_elements(By.TAG_NAME, "p")  # 7
    for i in variants:
        match i.text:
            case "М1":
                i.click()
            case "М42":
                i.click()
            case "М45":
                i.click()
    nextbtn = driver.find_element(By.NAME, "next")
    nextbtn.click()

    endbnt = driver.find_element(By.XPATH, "/html/body/div[1]/div[3]/div/div/section[1]/div[1]/div[3]/div/div/form/button")
    endbnt.click()
    sleep(1000)




